package com.lcx.plugin.entity;

import cn.hutool.core.util.StrUtil;
import com.lcx.plugin.enums.MysqlTypeMatch;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 类型隐射信息
 *
 * @author makejava
 * @version 1.0.0
 * @since 2018/07/17 13:10
 */
@Data
@NoArgsConstructor
public class TypeMapper implements AbstractItem<TypeMapper> {
    /**
     * excel类型
     */
    private String excelType;
    /**
     * jdbc类型
     */
    private String jdbcType;
    /**
     * 默认长度
     */
    private String defaultLength;

    public TypeMapper(MysqlTypeMatch matchType) {
        this.excelType = matchType.getExcelType();
        this.jdbcType = matchType.getJdbcType();
        this.defaultLength = matchType.getDefaultLength();
    }

    @Override
    public TypeMapper defaultVal() {
        return new TypeMapper(MysqlTypeMatch.STRING);
    }

    public boolean paramCheckSuccess() {
        return StrUtil.isNotBlank(excelType)
                && StrUtil.isNotBlank(jdbcType)
                && StrUtil.isNotBlank(defaultLength);
    }
}
